
In JavaScript don’t have any overloading concept. It just counts how many parameters pass the function. JavaScript also allows to any type passing the function then inside the function we will check the type of the function. Basically, JavaScript read the code top to bottom. If we pass the how many parameters the function executes the at last the function and other overloading function are not executing. So, we understand why JavaScript doesn’t allows to function overloading but it allows to pass the parameters. Now given bellow the code and explain the code:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
function ParameterPass(p1, p2, p3)
{
console.log(p1);
console.log(p2);
console.log(p3);
};
ParameterPass("one");
ParameterPass("one",2);
ParameterPass("one",2,true);
</script>
</body>
</html>
In this code we see the passing the parameter. We have a function name as “ParameterPass”. The function takes the three parameter and print the output in to the console. If any parameter is missing then it passes the undefine and also it prints the console.